import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store'

// 去掉路由重定向的那个的报错信息
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

const router = new Router({
    routes: [
        {
            path: '/login',
            name: 'Login',
            component: () => import('@/views/entry/Login'),
        },
    ]
})


router.beforeEach((to, from, next) => {
    if(to.path === '/') {
        next('/login')
    } else {
        next()
    }
})

export default router


// export default new Router({
//     routes: [{
//         path: '/',
//         name: 'HelloWorld',
//         component: HelloWorld
//     }]
// })
